#!/bin/bash
clear

TEXT='\033[30;107;2m'
INFO='\033[97;44m'
WARNING='\033[97;43m'
ERROR='\033[97;41m'
SUCCESS='\033[97;42m'
GREEN='\033[92m'
YELLOW='\033[93m'
RESET='\033[0m'

if [ "${EUID}" -ne 0 ]; then
    echo -e "${ERROR} ERROR ${RESET}${TEXT} You need to run this script as root! ${RESET}"; exit 1
fi

WIREGUARD_CONFIG="/etc/wireguard/wg0.conf"
echo "Which WireGuard user do you want to remove?"
cat $WIREGUARD_CONFIG | grep start | awk '{ print $2 }'

read -rp "Type in Client Name : " -e USERNAME
sed -i "/\# $USERNAME start/,/\# $USERNAME end/d" $WIREGUARD_CONFIG
rm -f /etc/wireguard/clients/$USERNAME/$USERNAME.conf
echo "Client $USERNAME has been removed."

systemctl restart wg-quick@wg0
